import type { AddressItem } from '@/types/global'
import { http } from '@/utils/http'
/**
 * 新增收货地址接口方法
 * @param data 请求参数新增地址信息
 * @returns id 新增地址id
 */
export const addAddressAPI = (data: AddressItem) =>
  http.post<{ id: number }>('/member/address', data)
/**
 * 获取收货地址列表接口方法
 * @returns 地址列表
 */
export const getAddressListAPI = () => http.get<AddressItem[]>('/member/address')
/**
 * 获取收货地址详情的接口方法
 * @param id 收货地址id(path参数)
 */
export const getAddressInfoAPI = (id: string) =>
  http.get<AddressItem>(`/member/address/${id}`)
/**
 * 修改收货地址接口方法
 * @param data 修改地址信息
 */
export const updateAddressAPI = (data: AddressItem) =>
  http.put<{ id: number }>(`/member/address/${data.id}`, data)
/**
 * 删除已有收货地址的接口方法
 * @param id 收货地址id(path参数)
 * @returns
 */
export const deleteAddressAPI = (id: string) =>
  http.delete<{ id: string }>(`/member/address/${id}`)
